from PIL import Image, ImageDraw, ImageFont

# 创建画布
img = Image.new('RGB', (500, 300), color='white')
draw = ImageDraw.Draw(img)

# 定义字体
font = ImageFont.load_default()

# 绘制方程与解
draw.text((10, 10), "方程: 2x - 4 = 0", fill="black", font=font)
draw.text((10, 50), "解: x = 2.00", fill="blue", font=font)

# 绘制分隔线
draw.line((10, 80, 490, 80), fill="black", width=2)

# 保存图像
img_path = "linear_equation_solution.png"
img.save(img_path)
print(f"图形已保存为 {img_path}")